package com.sulent.frame.file.common.config;

import com.sulent.frame.file.common.properties.MinioConfigProperties;
import com.sulent.frame.file.utils.SubMinioClient;
import io.minio.MinioAsyncClient;
import io.minio.MinioClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName MinioConfig
 * @Description: TODO
 * @Author Submerge.
 * @Since 2024/2/5 9:49
 * @Version 1.0
 */
@Configuration
@EnableConfigurationProperties(value = MinioConfigProperties.class)
public class MinioConfig {

    @Bean
    public SubMinioClient subMinioClient (MinioConfigProperties properties){
        return new SubMinioClient(MinioAsyncClient.builder().endpoint(properties.getEndpoint()).credentials(properties.getAccessKey(), properties.getSecretKey()).build());
    }

    @Bean
    public MinioClient minioClient(MinioConfigProperties properties){
        return MinioClient.builder().endpoint(properties.getEndpoint()).credentials(properties.getAccessKey(), properties.getSecretKey()).build();
    }






}
